<!doctype html>
<html>
<head>
	<meta charset="utf-8">
	<title>crossdomain | Flash LocalConnection</title>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge">
	<style>
	body, button{
		font-family: Verdana, Arial;
		color: #333;
	}
	h1{
		text-align:center;
		font-size:24px;
	}
	.wrapper{
		padding:10px;
		width:640px;
	}
	.wrapper, #child{
		border:#A11111 2px solid;
	}
	#info{
		color:#00F;
	}
	</style>
</head>
<body>
	<h1>crossdomain using Flash LocalConnection</h1>
	<div class='wrapper'>
		<p>Host window</p>
		<button id='trigger'>Send Message</button>
		<p id='info'></p>
		<div id='boundingBox'></div>
		<iframe width='600' height='140' 
		id='child' src='http://www.b.com/crossdomain/flash-localconnection/iframe.html'></iframe>
	</div>
	<script type="text/javascript" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script> 
	<script src='LocalConnector.js'></script>
	<script>
	YUI().use('base', 'local-connector', function(Y){

			var swfURL = 'localconnector.swf',
			     info = Y.one('#info'),
				 button = Y.one('#trigger'),
				 connector = new Y.LocalConnector({
					boundingBox: Y.one('#boundingBox'),
					selfName: '_endpoint1',
					targetName: '_endpoint2',
					allowDomain: 'www.b.com',
					swfURL: swfURL
				});
			
			connector.on('swfReady', function(){
				button.on('click', function(){
					connector.sendMessage("host message");
				});
			});
			connector.on('message', function(event){
				info.set('innerHTML', "receive message: "+ event.message + new Date());
			});
	});
	</script>
	
</body>
</html>
